define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'share/user/index' + location.search,
                    add_url: 'share/user/add',
                    edit_url: 'share/user/edit',
                    //del_url: 'share/user/del',
                    multi_url: 'share/user/multi',
                    import_url: 'share/user/import',
                    addchange_url:'share/user/addchange',
                    table: 'share_user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns:true,
                fixedRightNumber:1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'user.nickname', title: '姓名',operate:'LIKE'},
                        {field: 'user.username', title: '账号',operate:'LIKE',visible: false},
                        {field: 'user.mobile', title: '手机号',operate:'LIKE',visible: false},
                        {field: 'user.mobile_xing', title: '手机号', operate:false},
                        {field: 'role', title: __('Role'), searchList: {"0":__('无'),"1":__('视力健康大使'),"2":__('区域服务商'),"3":__('城市服务商')}, formatter: Table.api.formatter.status},
                        {field: 'province_name', title: '省', operate:'LIKE'},
                        {field: 'city_name', title: '市', operate:'LIKE'},
                        {field: 'area_name', title: '区', operate:'LIKE'},
                        {field: 'addtime', title: __('Addtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'parent_id', title: __('Parent_id')},
                        {field: 'total_price', title: __('Total_price'), operate:false},
                        {
                            field: 'operate',
                            title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            buttons: [],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
